import Vue from 'vue'
import {checkFileIsIllegal} from './ant_handler.js'

import {
  Select,
  Dropdown,
  TimePicker,
  DatePicker,
  TreeSelect,
  AutoComplete,
  Cascader,
  Upload,
  Affix,
  Popover
} from 'ant-design-vue'

// 日期浮层
TimePicker.props.getCalendarContainer = (triggerNode) => {
  return triggerNode.parentNode || document.body
}

DatePicker.props.getCalendarContainer = (triggerNode) => {
  return triggerNode.parentNode || document.body
}

// 其他选择框浮层
Select.props.getPopupContainer.default = (triggerNode) => {
  return triggerNode.parentNode || document.body
}

Dropdown.props.getPopupContainer.default = (triggerNode) => {
  return triggerNode.parentNode || document.body
}

TreeSelect.props.getPopupContainer.default = (triggerNode) => {
  return triggerNode.parentNode || document.body
}
AutoComplete.props.getPopupContainer.default = (triggerNode) => {
  return triggerNode.parentNode || document.body
}

Cascader.props.getPopupContainer.default = (triggerNode) => {
  return triggerNode.parentNode || document.body
}

Popover.props.getPopupContainer.default = (triggerNode) => {
  return triggerNode.parentNode || document.body
}

// Upload.props.accept.default = '.doc,.docx,audio/*,video/*,image/*,text/plain,.xlsx,.xls,.csv,.pdf,.zip,.rar,.gz,.pptx,.ppt'


// Upload.props.beforeUpload.default = (file, fileList)=> {
//   let isIllegal = checkFileIsIllegal(file.name)
//   if (isIllegal) {
//     message.info('文件类型非法')
//   }
//   return !isIllegal
// }

Affix.props.target.default = () => {
  return document.getElementById('app')
}

Vue.use(Select)
Vue.use(Dropdown)
Vue.use(TimePicker)
Vue.use(DatePicker)
Vue.use(TreeSelect)
Vue.use(AutoComplete)
Vue.use(Cascader)
Vue.use(Upload)
Vue.use(Popover)




